<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/header.jsp" %>

<script type="text/javascript" >
//首页初始化
var scripts = [null, null];
	$('.page-content-area').ace_ajax('loadScripts', scripts, function() {
		 
		$("#orgId").orgTreeSelect({
			checkType:"org", 
			clickType:"org",
			defaultOrgId:"${fns:getOrgId()}",
			defaultOrgName:'<hw:orgName orgId="${fns:getOrgId()}" />',
			queryRootOrgId:"${fns:getOrgId()}"
		});
		
			//时间插件切换目录后失效，加载前清下$("#ui-datepicker-div")
			$("#ui-datepicker-div").remove();
			//时间控件（开始日期）
			var startTime = $("#startTime").datepicker({
				showOtherMonths: true,
				selectOtherMonths: false,
				dateFormat:'yy-mm-dd'
			}).datepicker("setDate",lastMonth(new Date()));
			
			//时间控件（结束日期）		
			var endTime = $("#endTime").datepicker({
				maxDate:new Date(),
				showOtherMonths: true,
				selectOtherMonths: false,
				dateFormat:'yy-mm-dd',
			}).datepicker("setDate", new Date());
			
		queryLogin();
		
		function setFormData() {
	        setTimeout(function() {
	        	startTime.datepicker("setDate", lastMonth(new Date()));
	        	endTime.datepicker("setDate", new Date());
	        	$("#orgId").val("${fns:getOrgId()}");
	        }, 200); 
	    } 
		
		setFormData();
		
		$("#stisticForm").on("reset",setFormData);
		
	});
	
function lastMonth(date){
	var month =new Date(date.setMonth(date.getMonth() - 1));
	return month;
}

 // 查询事件
function queryList(){
	    $("#stisticForm").validate({
		errorElement: 'label',
		errorClass: 'help-block',
		focusInvalid: false,
		rules: {
		startTime: {
			isDate10:true,
			required: true,
			compareDate:"#endTime"
			},
		 endTime: {
			 required: true,		
			 isDate10:true
			 }		       
		},
	 messages: {
		startTime: {
			required: "请选择开始时间!"
			        },
		endTime: {
			required: "请选择结束时间!"
		}  
	}
	});
	    
	if (!$("#stisticForm").valid()) {
		return;
	}
	
	queryLogin();
}

function queryLogin(){
	$("#loginInfos").hide();
	var startTime = $("#startTime").val();
	var endTime = $("#endTime").val();
	var orgId = $("#orgId").val();
	var params =  { "startTime":startTime, "endTime": endTime, "orgId":orgId};
	$("#loginInfos").load("${ctx}/logInfo/query?"+new Date().getTime(), params);
	$("#loginInfos").show();	
}

</script>

<div class="row">
	<div class="col-xs-12">	
		<div class="widget-box widget-color-blue2">			
			<div class="widget-header">
				<h5 class="widget-title">统计查询</h5>
				<!-- #section:custom/widget-box.toolbar -->
				<div class="widget-toolbar">
					<a href="#" data-action="fullscreen" class="orange2"><i class="ace-icon fa fa-expand"></i></a>
					<a href="#" data-action="collapse"><i class="ace-icon fa fa-chevron-up"></i></a>
					<a href="#" data-action="close"><i class="ace-icon fa fa-times"></i></a>
				</div>
				<!-- /section:custom/widget-box.toolbar -->
			</div>
			<div class="widget-body">
				<div class="widget-main no-padding">				
					<form class="form-horizontal" id="stisticForm" name="stisticForm">
						<fieldset>
						    <div class="row">
								<div class="form-group col-xs-6">
									<label class="col-sm-3 control-label no-padding-left" for="startTime">登录时间</label>
									<div class="col-sm-9">
										<div class="clearfix">
											<div class="input-daterange input-group">
												<input type="text" class="input-sm form-control" name="startTime" id="startTime" readonly="readonly"/>
												<span class="input-group-addon">
													<i class="fa fa-exchange"></i>
												</span>
		
												<input type="text" class="input-sm form-control" name="endTime" id="endTime" readonly="readonly"/>
											</div>
										</div>
									</div>
								</div>							
						    	<div class="form-group col-xs-6">
									<label class="col-sm-3 control-label no-padding-left" for="orgId">所属机构</label>
									<div class="col-sm-9">
										<div class="clearfix">
											 <input type="text" id="orgId" name="orgId" class="col-xs-10"  onfocus="(this)"/>
										</div>
									</div>
								</div>
							</div>
						</fieldset>
						<div class="form-actions center">
							<button class="btn btn-sm btn-info" type="button" id="btn_query" onclick="queryList()">
								<i class="icon-on-right ace-icon fa fa-search bigger-110"></i>
								查询
							</button>
							&nbsp; &nbsp; &nbsp;
							<button class="btn btn-sm" type="reset">
								<i class="ace-icon fa fa-refresh bigger-110"></i>
								重置
							</button>
						</div>		
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
		
		
	<div id="loginInfos"></div>	



